#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void merge(vector<int>& v,int minIndex,int maxIndex)
{
    sort(v.begin()+minIndex,v.begin()+maxIndex+1);
    cout<<"The sorted vector is:"<<endl;
    for(int i=minIndex;i<=maxIndex;++i)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void mergeSort(vector<int>& v,int minIndex,int maxIndex)
{
    
    if(maxIndex>minIndex+1)
    {
        int mid = (maxIndex+minIndex)>>1;
        mergeSort(v,minIndex,mid);
        mergeSort(v,mid+1,maxIndex);
    }
    merge(v,minIndex,maxIndex);
}
int main()
{
    cout<<"Enter the numbers:"<<endl;
    vector<int> v;
    int n;
    while(n!=-1)
    {
        cin>>n;
        v.push_back(n);
    }
    v.pop_back();
    int minIndex = 0;
    int maxIndex = v.size()-1;
    mergeSort(v, minIndex, maxIndex);
    cout<<"The sorted vector is:"<<endl;
    for(int i=0;i<v.size();++i)
    {
        cout<<v[i]<<" ";
    }
    return 0;
}